<?php
namespace Admin\Controller;
class PriceController extends CommonController{
    public function _initialize() {
		parent::_initialize();
        $this->_mod = D('Price');
        $this->house = getHouseName($_GET['house_id'],true,'id,title,area_id');
    }

    public function _before_index() {
        $big_menu = array(
            'title' => '增加价格',
            'iframe' =>U('Price/add',array('house_id'=>$_GET['house_id'])),
            'id' => 'add',
            'width' => '520',
            'height' => '210',
        );
        $this->_ajaxedit = 1;
        $this->assign('big_menu',$big_menu);
        $p = I('p',1,'intval');
        $this->assign('p',$p);
    }

    protected function _search() {
        $map = array();
        $map['house_id'] = $_GET['house_id'];
        ($time_start = I('get.time_start')) && $map['add_time'][] = array('egt', strtotime($time_start));
        ($time_end = I('get.time_end')) && $map['add_time'][] = array('elt', strtotime($time_end)+(24*60*60-1));
        ($keyword = I('get.keyword')) && $map['price'] = array('like', '%'.$keyword.'%');

        $this->assign('search', array(
            'time_start' => $time_start,
            'time_end' => $time_end,
            'keyword' => $keyword,
        ));
        return $map;
    }

    public function _before_insert($data){
        $data['add_time'] = strtotime($_POST['add_time']);
        $data['years'] = date('Y-m-d',$data['add_time']);
        $data['house_id'] = $_POST['house_id'];
        $data['area_id'] = $_POST['area_id'];
        return $data;
    }

    public function _before_update($data){
        $data['add_time'] = strtotime($_POST['add_time']);
        $data['years'] = date('Y-m-d',$data['add_time']);
        $data['area_id'] = $_POST['area_id'];
        return $data;
    }

}